package de.koller.aframe.util.misc;

import java.util.Random;
import org.jbox2d.collision.AABB;

public class ARangeD {
	
	public double lowerBound;
	public double upperBound;

	public ARangeD() {
	
	}
	
	public ARangeD( double lowerBound, double upperBound ) {
		this.lowerBound = lowerBound;
		this.upperBound = upperBound;
	}
	
	public void set( double lower, double upper ) {
		this.lowerBound = lower;
		this.upperBound = upper;
	}
	
	public boolean isIn( double value ) {
		if( lowerBound > value )
			return false;
		if( upperBound <= value )
			return false;
		return true;
	}
	
	/** returns a scaled value. The lower bound is 0, the upper bound 1 */
	public double getScaled( double value ) {
		return 1. / (upperBound - lowerBound) * (value - lowerBound);
	}
	
	public double getRandomValue( Random rnd ) {
		return (rnd.nextDouble() * (upperBound - lowerBound)) + lowerBound;
	}

}
